package com.wgy.day37Stream流.常用方法;

import java.util.stream.Stream;

/*
Stream流中的常用方法concat:用于把Stream流中多个流的组合到一起
static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b):把多个流中组合在一起,并返回一个新的流

concat方法:是Stream类的静态方法
*/
public class Demo09Stream_concat {
    public static void main(String[] args) {
        //1.获取一个Stream流
        Stream<String> stream = Stream.of("张三丰", "赵敏", "张无忌", "周芷若", "张翠山");
        //2.再获取一个Stream流
        String[] arr={"喜羊羊","美羊羊","懒羊羊","灰太狼","红太狼"};
        Stream<String> stream1 = Stream.of(arr);
        //3.使用Stream流中的静态方法concat,把两个流组合到一起
        Stream<String> stream2 = Stream.concat(stream, stream1);
        //4.遍历组合后的流
        stream2.forEach(name-> System.out.println(name));
    }
}
